package com.c2b.algorithm.newcoder.tree;

import java.util.ArrayList;

/**
 * <a href="https://www.nowcoder.com/practice/91b69814117f4e8097390d107d2efbe0?tpId=295&tqId=23454&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj">按之字形顺序打印二叉树</a>
 * <p>给定一个二叉树，返回该二叉树的之字形层序遍历，（第一层从左向右，下一层从右向左，一直这样交替）</p>
 * <p>数据范围：0≤n≤1500,树上每个节点的val满足∣val∣<=1500<br>
 * 要求：空间复杂度：O(n)，时间复杂度：O(n)</p>
 * <pre>
 *      1
 *     / \
 *    2   3
 *       / \
 *      4   5
 *
 * 遍历结果：
 * [[1],[3,2],[4,5]]
 * </pre>
 *
 * @author c2b
 * @since 2023/3/14 10:40
 */
public class BM0027Print_M {

    public ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
        return null;
    }

    public static void main(String[] args) {
        TreeNode treeNode = new TreeNode(1);
        treeNode.left = new TreeNode(2);
        treeNode.right = new TreeNode(3);
        treeNode.right.left = new TreeNode(4);
        treeNode.right.right = new TreeNode(5);
        BM0027Print_M bm0027Print_m = new BM0027Print_M();
        for (ArrayList<Integer> arrayList : bm0027Print_m.Print(treeNode)) {
            for (Integer integer : arrayList) {
                System.out.println(integer);
            }
        }

    }
}
